/**
 * @Description: 数泽MES
 * @Author: 数泽
 * @Date: 2023-10-27 16:08:02
 */

export function useCrmAllCreate(crmOption) {
// CRMAllCreate使用的
  /**
   * 创建成功
   */
  function saveSuccess(data) {
    if (data.type == 'customer') {
      handleHandle(data)
      if (data.createContacts) {
        crmOption.createType = 'contacts'
        crmOption.createAction = {
          type: 'relative',
          crmType: 'customer',
          data: {
            customer: data.data
          }
        }
        crmOption.createShow = true
      }
    }
  }

  function handleHandle(data) {
    // 编辑是个动作，不是编辑成功。不执行操作
    if (['edit'].includes(data.type)) {
      return
    }

    if (['alloc', 'get', 'transfer', 'transform', 'delete', 'put_seas', 'exit-team'].includes(data.type)) {
      crmOption.showDview = false
    }
  }

  return {
    saveSuccess, handleHandle
  }
}